package com.SparkCore.framwork.common

import com.SparkCore.framwork.util.EnvUtil
import org.apache.spark.{SparkConf, SparkContext}

trait TApplication {
  def start(master:String = "local[*]", app: String = "Application")( op: => Unit): Unit ={
    //TODO 建立和Spark框架的连接
    val sparkConf = new SparkConf().setMaster(master).setAppName(app)
    val sc = new SparkContext(sparkConf)
    EnvUtil.put(sc)
    try{
      op
    }catch {
      case ex: Throwable => println(ex.getMessage)
    }

    sc.stop()
    EnvUtil.clear()
  }

}
